@inject HttpClient _http
@inject IStringLocalizer<Resource> _localizer

@if (_model != null)
{
     <div class="row">
        <div class="col-4">
            <a class="dash-widget dash-link dash-stats" href="/admin/blog/">
                <span class="dash-stats-value">@_model.TotalPosts</span>
                <span class="dash-stats-name">@_localizer["posts"]</span>
            </a>
        </div>
        <div class="col-4">
            <a class="dash-widget dash-link dash-stats" href="/admin/pages/">
                <span class="dash-stats-value">@_model.TotalPages</span>
                <span class="dash-stats-name">@_localizer["pages"]</span>
            </a>
        </div>
        <div class="col-4">
            <a class="dash-widget dash-link dash-stats" href="/admin/newsletter/subscribers/">
                <span class="dash-stats-value">@_model.TotalSubscribers</span>
                <span class="dash-stats-name">@_localizer["subscribers"]</span>
            </a>
        </div>
    </div>
}

@code {
	protected AnalyticsModel _model;

	protected override async Task OnInitializedAsync()
	{
		_model = await _http.GetFromJsonAsync<AnalyticsModel>("api/analytics");
	}
}
